/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.jims.api.v1.controller.sync;

import com.baomidou.kisso.my.controller.BaseController;
import com.jims.master.common.data.Message;
import com.jims.master.common.utils.Encodes;
import com.jims.master.common.utils.SecurityUtil;
import com.jims.master.modules.sync.entity.Diagnosis;
import com.jims.master.modules.sync.entity.SummaryLeaveHospital;
import com.jims.master.modules.sync.service.DiagnosisService;
import com.jims.master.modules.sync.service.SummaryLeaveHospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 出院小结Controller
 * @author WangYQ
 * @version 2018-08-17
 */
@RestController
@RequestMapping(value = "/Diagnosis")
public class DiagnosisController extends BaseController {

	@Autowired
	private SummaryLeaveHospitalService summaryLeaveHospitalService;
    @Autowired
    private DiagnosisService diagnosisService;
    /***
     * 获取诊断
     * @param visitId
     */
    @RequestMapping(value = "/V100/getDiagnosis",method ={RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public String getDiagnosis(@RequestParam(required = true)String visitId) {
        SummaryLeaveHospital summaryLeaveHospital = summaryLeaveHospitalService.getByVisitId(visitId);
        List<Diagnosis> diagnosisInList = new ArrayList<Diagnosis>();
        if(summaryLeaveHospital!=null){
            diagnosisInList= diagnosisService.findEmrDiagnosisList(summaryLeaveHospital.getId());
        }
        Message mes = new Message();
        mes.setData(diagnosisInList);
        return SecurityUtil.encryptMsgData(mes);
    }
    /***
     * 获取诊断
     * @param id
     */
    @RequestMapping(value = "/V100/getBasis",method ={RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public String getBasis(@RequestParam(required = true)String id) {
        Diagnosis diagnosis = diagnosisService.get(id);
        String basis =null;
        if(diagnosis!=null){
            basis=diagnosis.getBasis();
        }
        Message mes = new Message();
        mes.setData(basis);
        return SecurityUtil.encryptMsgData(mes);
    }
}